<template>
  <div>
    <basic-container>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>活动</el-breadcrumb-item>
        <el-breadcrumb-item>天天领红包</el-breadcrumb-item>
      </el-breadcrumb>
    </basic-container>

    <basic-container>
      <!-- <template>
				<div style="margin: 20px;">
					<span style="margin-right: 40px;">活动名称：用家乡话秀出你的新年flag </span>
					<span>活动时间：2021.02.08—2021.02.18</span>
				</div>
			</template> -->
      <avue-crud
        :table-loading="loading"
        ref="crud"
        :data="data"
        v-model="form"
        :option="option"
        :page.sync="page"
        @on-load="getList"
          @search-reset="from = {}"
        @refresh-change="refreshChange"
         @search-change="searchChange"
      >
        
        <!-- 				
				<template slot-scope="scope" slot="menuLeft">
					<el-button type="primary" icon="el-icon-download" size="small" plain @click="handleExcel()">导出Excel</el-button>
				</template> -->
      </avue-crud>
    </basic-container>
  </div>
</template>


<script>
import { catUrl } from "@/config/env";
import { common } from "@/api/cat/httpRequest";
import { userGetList as baseURL } from "@/api/cat/baseUrls";
export default {
  data() {
    return {
      loading: false,
      page: {
        total: 0,
        pageSize: 10,
      },
      type: true,
      data: [],
      params: {},
      form: {},
      default: {
        // orderByList: "stats_date&DESC",
      },
      option: {
        index: true,
        indexLabel: "序号",
        addBtn: false,
        editBtn: false,
        viewBtn: false,
        delBtn: false,
        excelBtn: false,
        selection: true,
        border: true,
        menu: false,
        column: [
          {
            label: "用户昵称",
            prop: "user_name",
            type: "input",
            // format: "yyyy-MM-dd",
            // valueFormat: "yyyy-MM-dd",
            search: true,
          },
          {
            label: "用户ID",
            prop: "user_id",
            type: "input",
            search: true,
          },
          {
            label: "渠道号",
            prop: "channel_id",
            type: "input",
            search: false,
          },
          {
            label: "参与活动时间",
            prop: "create_time",
            type: "daterange",
            search: true,
          },
          {
            label: "充值金额",
            prop: "recharge_type",
            type: "select",
            width: "110px",
            dicData:[{label:'38',value:1},{label:'58',value:2},{label:'98',value:3}],
            search: true,
          },
          {
            label: "已连续领取天数",
            prop: "days_state",
            type: "input",
            search: false,
          },
          {
            label: "已领红包总额",
            prop: "amount",
            type: "input",
            search: false,
          },
          // {
          //   label: "累计提现金额",
          //   prop: "share_detail_pv",
          //   type: "input",
          //   width: "110",
          //   search: false,
          // },
        ],
      },
    };
  },
  // async created() {
  // 	let data = await common(`${catStatisticsActiveFlag.getListByLeave}/2`)
  // 	if (data.code == 1) {
  // 		this.option.column[4].dicData = data.data;
  // 	}
  // },
  methods: {
    searchChange(params, done){
    let item = {"user_name":params.user_name,start_time:params.create_time?params.create_time[0]:'',end_time:params.create_time?params.create_time[1]:'',"user_id":params.user_id,"recharge_type":params.recharge_type}
      this.loading = false;
      this.params = {...item,...this.page}
      this.getList()
       if (done) done();
    },
    //数据导出
    async handleExcel() {
      this.loading = true;
      //处理搜索条件
      let params = { ...this.$refs.crud.searchForm };
      this.default.orderByList = "stats_date&DESC";
      this.default.orderByList = this.default.orderByList + params.order;
      delete params.order;
      // if (params.statistics_date_search && params.statistics_date_search.length > 0) {
      // 	params.statistics_date = `!<>!${params.statistics_date_search}`
      // }
      // delete params.statistics_date_search;

      //调用导出接口
      handleExcelCat(
        // this.$export,
        // baseURL.pageAndParam,
        // { ...params, ...this.default },
        // "新年活动数据统计",
        // this.page.total,
        // [...this.option.column]
      );
      this.loading = false;
    },
    /**获取列表 */
    async getList(param) {
    //   this.loading = true;
      //清空表格列表
      this.data = [];
      //发送请求获取数据
      let response = await common(
      	baseURL.getList, { ...this.params,
      		...this.default
      	},
      	this.page,
      	"POST"
      );
    //   this.page = response.page;
      this.data = response.data.records;
      this.loading = false;
    } /**刷新 */,
    refreshChange() {
      this.form ={}
      this.getList();
    },
  },
};
</script>
